<template>
  <div class="hello">
    <h2>Action</h2>
    <button @click="$store.dispatch('increment')">增加增加</button>
    <br />
    <br />
    <button @click="$store.dispatch('incrementAsync')">增加增加异步settimeout</button>
    <p>改变后的值：{{ $store.state.count }}</p>
    <button @click="$store.dispatch('incrementLocal')">组件内调用</button>
    <p>组件内调用后的值：{{ $store.state.countLocal }}</p>
    <button @click="add">重新命名为add</button>
<br />
<br />
    <button @click="$store.dispatch('actionB')">组合异步事件</button>
    <p>组合promise-actionA事件对应的值：{{ $store.state.someCount }}</p>
    <p>组合promise-actionB：{{ $store.state.someOtherCount }}</p>
  </div>
</template>

<script>
import { mapActions } from 'vuex'

export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  methods: {
    ...mapActions(['incrementLocal']),
    ...mapActions({
      add: 'increment'
    })
  },
  computed: {}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
